﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="HRMCoreCompetencyList.aspx.cs" Inherits="KPIS.GERP.GHRMS.APP.App_UI.Forms.HRMCoreCompetencyList" %>
<%@ Register src="../Controls/user.ascx" tagname="user" tagprefix="uc1" %>
<%@ Register src="../Controls/DatePicker.ascx" tagname="DatePicker" tagprefix="uc2" %> 

<asp:Content ID="Content1" runat="server" contentplaceholderid="ContentPlaceHolder1">
    <%--cboCompentencyLevel--%><title>โครงสร้างกรอบอัตรากำลัง</title><link href="../../Styles/CssClass.css" rel="stylesheet" type="text/css" /><link href="../../Styles/StyleSheet.css" rel="stylesheet" type="text/css" /><script src="../../Scripts/DatePicker.js" type="text/javascript"></script><script src="../../Scripts/Common.js" type="text/javascript"></script><script src="../../Scripts/jquery-1.9.0.min.js" type="text/javascript"></script><script type="text/javascript">
        function minmax(value, min, max) {
            if (parseInt(value) < 0 || isNaN(value)) {
                alert('กรุณากรอกน้ำหนัก');
            } else if (parseInt(value) > 100) {
                alert('น้ำหนักต้องไม่เกิน 100');
                return 100;
            } else return value; 
            {

            }
        }
    </script><telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Panel2">
                <UpdatedControls>                    
                    <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>                    
                    <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="Panel2" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
        Height="100%" Width="75px" Transparency="50">
        <table style="height: 100%; width: 100%" border="0">
            <tr>
                <td width="100%" align="center" valign="middle">
                    <img alt="Loading..." 
                        src="../Images/Buttons/loading.gif" 
                        style="border: 0px;" />
                </td>
            </tr>
        </table>
    </telerik:RadAjaxLoadingPanel>

    <table width="1000" cellpadding="0" cellspacing="0">
        <tr>
            <td width="280" valign="top"> <!-- ส่วน TreeView -->
                <div class="Background980V3" style="width: 270px; min-height: 440px; margin-right:10px">
                    <table width="100%">
                        <tr class ="tableHeader">
                            <td class ="tableHeader" valign="middle">
                                ค้นหา : <telerik:RadTextBox ID="txtSearch" Runat="server" Width="140px" />
                                <asp:ImageButton ID="cmdSearch" runat="server" onclick="cmdSearch_Click" 
                                    ToolTip="กดปุ่มเพื่อเริ่มค้นหาข้อมูล" ImageUrl="~/App_UI/Images/Buttons/Magnifier.gif" />
                            </td>
                        </tr>
                    </table>
                    <asp:Panel ID="Panel2" runat="server" Width="100%" Height="100%" ScrollBars="Auto">
                        <telerik:RadTreeView ID="RadTreeView1" Runat="server" 
                                                DataFieldID="ID" 
                                                DataFieldParentID="Parent_id" 
                                                DataTextField="Name" 
                                                DataValueField="ID" 
                                                OnNodeExpand="RadTreeView1_NodeExpand" 
                                                onnodeclick="RadTreeView1_NodeClick"
                                                EnableDragAndDrop="False" 
                                                EnableDragAndDropBetweenNodes="true"
                                                CssClass="MinHeightSet"
                                                CausesValidation="False" />
                    </asp:Panel>
                </div>
           </td>
           <td valign = "top"> <!-- ส่วนของ Grid -->
               <div class="Background980V3" style="width: 680px; margin-bottom: 5px; ">
                   <asp:Panel ID="PanelFilter" runat="server" Width="700px" ScrollBars="Auto">
                       <table align="center" width = "650px">
                           <tr>
                               <td align="right" >ประเภทบุคลากร : </td>
                               <td align = "left">
                                   <telerik:RadComboBox 
                                        ID="cmbEmpType" 
                                        DataTextField = "Name"
                                        DataValueField = "Sequence"
                                        AllowCustomText="true" 
                                        runat="server" 
                                        Width="200px"
                                        Filter ="Contains"
                                        AutoPostBack="True"
                                        CausesValidation ="false"
                                        ValidationGroup = "EmpType"
                                        EmptyMessage="... เลือกประเภทบุคลากร ..."                 
                                        onselectedindexchanged="cmbEmpType_SelectedIndexChanged">
                            </telerik:RadComboBox>
                          </td>
                       </tr>
                   </table>
                </asp:Panel>
            </div> 
            
            <div class="Background980V3" style="width:690px; min-height: 413px; padding: 0px 5px 0px 5px;">
                <asp:Panel ID="Panel1" runat="server"  Width="100%" >
                <asp:Panel ID="panelCommand" runat="server" >
                    <table width="100%">
                        <tr>
                            <td  align="left" valign="top" bgcolor="#7DA5E0" width="100%" colspan="2" 
                                style="padding: 5px; color: #FFFFFF; font-weight: bold; font-family: 'Segoe UI'; font-size: 13px;">
                                 ข้อมูลสมรรถนะ/ ตำแหน่ง : <asp:Label runat="server" ID="lblNamePos"></asp:Label>
                            </td>
                        </tr>
                    </table> 
                    <div class="DivInfo" id="blockCommand" runat="server">
                    <table cellpadding="0" cellspacing="0">
                        <tr>
                            <td>
                                <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="ShowGrid" runat="server" OnClick="ShowGrid_Click">
                                     <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Buttons/Refresh.gif" />&nbsp;&nbsp;แสดงข้อมูลทั้งหมด
                                </asp:LinkButton>  
                                <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="AddNew" 
                                                runat="server" onclick="AddNew_Click">
                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Buttons/AddRecord.gif" />&nbsp;&nbsp;เพิ่มข้อมูลใหม่
                                </asp:LinkButton>
                                <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="Save_AddNew" 
                                                runat="server" onclick="Save_AddNew_Click" OnClientClick="javascript:return confirm('ต้องการบันทึกข้อมูลใช่หรือไม่')">
                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Buttons/saveDisk.gif" />&nbsp;&nbsp;บันทึกข้อมูล
                                </asp:LinkButton>  
                                <asp:LinkButton Font-Underline="False" Font-Weight="Bold" ID="Save_Edit" 
                                                runat="server" onclick="Save_Edit_Click" OnClientClick="javascript:return confirm('ต้องการบันทึกข้อมูลใช่หรือไม่')">
                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Buttons/saveDisk.gif" />&nbsp;&nbsp;บันทึกข้อมูล
                                </asp:LinkButton>
                                <asp:LinkButton ID="Delete" runat="server" CssClass="ControlLinkButton" OnClick="Delete_Click"
                                                OnClientClick="javascript:return confirm('ต้องการลบข้อมูลใช่หรือไม่')">
                                                <img style="border:0px;vertical-align:middle;" alt="" src="../Images/Buttons/Delete.gif" CommandName="GridDelete" />&nbsp;&nbsp;ลบข้อมูล
                                </asp:LinkButton>
                              </td>
                            </tr>
                      </table> 
                   </div>     
                </asp:Panel>    
                <asp:Panel ID="PanelGrid" runat="server" Height="330px" ScrollBars="Auto" Width="690px" Visible = "false">
                    <telerik:RadGrid ID="dgtCompetencyCtrl" runat="server" AllowAutomaticDeletes="True" 
                            AllowFilteringByColumn="True" AllowMultiRowEdit="True" 
                            AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True" 
                            AutoGenerateColumns="False" EnableAJAX="True" EnableAJAXLoadingTemplate="True" 
                            GridLines="None" 
                            GroupingSettings-GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;" 
                            GroupingSettings-GroupContinuedFormatString="" 
                            GroupingSettings-GroupContinuesFormatString="" 
                            GroupingSettings-GroupSplitFormat="" OnItemCommand="dgtCompetencyCtrl_ItemCommand" 
                            OnNeedDataSource="dgtCompetencyCtrl_NeedDataSource" Skin="Office2007" 
                        Width="670px" onitemdatabound="dgtCompetencyCtrl_ItemDataBound">
                        <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1" 
                                ClientDataKeyNames="pos_competency_seq" CommandItemDisplay="Top" DataKeyNames="pos_competency_seq" 
                                EditMode="PopUp" InsertItemPageIndexAction="ShowItemOnCurrentPage" 
                                NoMasterRecordsText="&lt; ไม่มีข้อมูล &gt;">
                            <CommandItemTemplate>
                            </CommandItemTemplate>

                               <Columns>
                                   <telerik:GridBoundColumn HeaderText="PK"  UniqueName="pos_competency_seq" DataField="pos_competency_seq" Visible="false">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn  UniqueName="core_competency_seq" DataField="core_competency_seq" Visible="false">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn  UniqueName="competency_level_seq" DataField="competency_level_seq" Visible="false">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn  UniqueName="expect_result" DataField="expect_result" Visible="false">
                                   </telerik:GridBoundColumn>
                                   <telerik:GridClientSelectColumn UniqueName="checkCol">
                                        <HeaderStyle Width="20px"/>
                                    </telerik:GridClientSelectColumn>
                                   <telerik:GridButtonColumn HeaderText="แก้ไข" ImageUrl="../Images/Buttons/Edit.gif" ButtonType="ImageButton" CommandName="GridEdit">
                                        <HeaderStyle Width="10%" />
                                   </telerik:GridButtonColumn>
                                   <telerik:GridBoundColumn HeaderText="สมรรถนะหลัก" DataField="core_competency_name" UniqueName="core_competency_name"
                                         ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="100%">
                                        <HeaderStyle Width="120px" />
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn HeaderText="ระดับสมภรรถนะ" DataField="level_name" UniqueName="level_name"
                                         ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="100%">
                                        <HeaderStyle Width="120px" />
                                   </telerik:GridBoundColumn>
                                   <telerik:GridBoundColumn HeaderText="น้ำหนัก" DataField="weight" UniqueName="weight"
                                         ShowFilterIcon="false" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" FilterControlWidth="100%">
                                        <HeaderStyle Width="70px" />
                                   </telerik:GridBoundColumn>
                                  <telerik:GridTemplateColumn HeaderText="ระดับคะแนนที่คาดหวัง" ReadOnly="True" ShowFilterIcon="false" FilterControlWidth="100%">
                                        <ItemTemplate>
                                             <asp:RadioButtonList runat="server" ID="rdoExpectResult" RepeatDirection="Horizontal" AutoPostBack="True" RepeatLayout="Flow" Enabled="False">
                                               <asp:ListItem Text="1" Value="1" />
                                                <asp:ListItem Text="2" Value="2" />
                                                <asp:ListItem Text="3" Value="3" />
                                                <asp:ListItem Text="4" Value="4" />
                                                <asp:ListItem Text="5" Value="5" /> 
                                              </asp:RadioButtonList>
                                       </ItemTemplate>
                                   </telerik:GridTemplateColumn>
                                 </Columns>
                               <PagerStyle AlwaysVisible="true" Mode="NextPrevNumericAndAdvanced" />
                         </MasterTableView>
                            <ClientSettings AllowColumnHide="True" AllowColumnsReorder="True" 
                                EnableRowHoverStyle="True" ReorderColumnsOnClient="True">
                                <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                            </ClientSettings>
                        </telerik:RadGrid>
                                                <span style="font-size: x-small; color:red">
                                                     
                                                    <asp:Literal runat="server" ID="ltrMessageError"  />
                                                </span>
                    </asp:Panel>
                <asp:Panel ID="PanelDetail" runat="server" Width = "690px" ScrollBars ="Auto">
                <table width="650" align ="center" >
                        <asp:Label runat="server" ID="lblPosCompentencySeq" Visible="False"></asp:Label>
                        <asp:Label runat="server" ID="lblPosSeq" Visible="False"></asp:Label> 
                        <asp:Label runat="server" ID="lblPosRef" Visible="False"></asp:Label> 
                    <tr>
                         <td>สมรรถนะหลัก :</td>
                         <td>
                                <telerik:RadComboBox ID="cboCoreCompetency" runat="server" DataValueField="core_competency_seq"
                                            DataTextField="core_competency_name"  Filter="Contains"  AutoPostBack="True"
                                            HighlightTemplatedItems="true" 
                                    onselectedindexchanged="cboCoreCompetency_SelectedIndexChanged">
                                </telerik:RadComboBox>
                         </td>
                     </tr>
                     <tr>
                         <td>ระดับสมรรถนะ :</td>
                         <td>
                             <telerik:RadComboBox ID="cboCompentencyLevel" runat="server" DataValueField="competency_level_seq"
                                            DataTextField="level_name"  Filter="Contains"  
                                            HighlightTemplatedItems="true">
                             </telerik:RadComboBox>
                         </td>
                      </tr>
                      <tr>
                         <td>น้ำหนัก : </td>
                         <td>
                             <telerik:RadNumericTextBox ID="txtWeight" Runat="server" MaxLength="3" MaxValue="100"
                                    onkeyup="this.value = minmax(this.value, 0, 100)">
                                    <NumberFormat DecimalDigits="0" ZeroPattern="n" />
                             </telerik:RadNumericTextBox> &nbsp;&nbsp;&nbsp;%
                         </td>
                      </tr>
                 </table>
              </asp:Panel>
              </asp:Panel>
            </div>
         </td>
       </tr> 
    </table>
  </asp:Content> 